package com.it.util;


import com.it.exception.GeneralException;
import org.springframework.util.ObjectUtils;

/**
 * 断言工具类
 */
public class AssertUtil {
    public  static void isNotEmpty(ResultCodeEnum resultCode,Object object) {
        if (ObjectUtils.isEmpty(object)){
            execute(resultCode);
        }
    };
    public  static void isEmpty(ResultCodeEnum resultCode,Object object) {
        if (!ObjectUtils.isEmpty(object)){
            execute(resultCode);
        }
    };
    public static void isTrue(ResultCodeEnum resultCode,boolean result) {
        if (!result){
            execute(resultCode);
        }
    }



    private static void execute(ResultCodeEnum resultCode){
        throw new GeneralException(resultCode.getMessage(),resultCode.getCode());
    };

}
